package com.hzh.cusviewdemo.Adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.hzh.cusviewdemo.R;

import java.util.List;

public class TopAdapter extends RecyclerView.Adapter<TopAdapter.MyHolder> {

    private List<String> dataList;

    public TopAdapter(List<String> dataList) {
        this.dataList = dataList;
    }

    @NonNull
    @Override
    public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = View.inflate(parent.getContext(), R.layout.item_top, null);
        return new MyHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyHolder holder, int position) {
        holder.it_tag.setText(dataList.get(position));
    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }

    static class MyHolder extends RecyclerView.ViewHolder {

        private TextView it_tag;

        public MyHolder(@NonNull View itemView) {
            super(itemView);
            it_tag = itemView.findViewById(R.id.it_tag);
        }
    }
}
